package version1;

/**
 * 普通的递归写法
 * 
 * 计算N的阶乘
 */
public class RecursionDemo1 {

    public static void main(String[] args) {
        System.out.println(getFactorialOfN(4));
    }

    private static int getFactorialOfN(int n) {
        if(n < 0){
            throw new RuntimeException("请输入大于等于零的正整数！");
        }
        if(n == 0 || n == 1){
            return 1;
        }
        return n * getFactorialOfN(n-1);
    }
}
